/*
 * Copyright 2022-2029 heshuixing(https://gitee.com/heshuixing)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mercury.ec.framework.air.core.client.impl.sunstn.convert;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.mercury.ec.framework.air.core.client.dto.order.cancel.AirOrderCancelReqDTO;
import com.mercury.ec.framework.air.core.client.dto.order.cancel.AirOrderCancelRespDTO;
import com.mercury.ec.framework.air.core.client.dto.order.create.AirOrderCreateReqDTO;
import com.mercury.ec.framework.air.core.client.dto.order.create.AirOrderCreateRespDTO;
import com.mercury.ec.framework.air.core.client.dto.order.issue.AirOrderIssueReqDTO;
import com.mercury.ec.framework.air.core.client.dto.search.detr.AirDetrReqDTO;
import com.mercury.ec.framework.air.core.client.dto.search.detr.AirDetrRespDTO;
import com.mercury.ec.framework.air.core.client.dto.search.detr.AirDetrRouteRespDTO;
import com.mercury.ec.framework.air.core.client.dto.search.pat.AirPatReqDTO;
import com.mercury.ec.framework.air.core.client.dto.search.pat.AirPatRespDTO;
import com.mercury.ec.framework.air.core.client.dto.search.patex.AirPatexReqDTO;
import com.mercury.ec.framework.air.core.client.dto.search.patex.AirPatexRespDTO;
import com.mercury.ec.framework.air.core.client.dto.search.rt.*;
import com.mercury.ec.framework.air.core.client.dto.search.rtkt.AirRtktReqDTO;
import com.mercury.ec.framework.air.core.client.dto.search.rtkt.AirRtktRespDTO;
import com.mercury.ec.framework.air.core.client.dto.search.xsfsi.AirXsfsiReqDTO;
import com.mercury.ec.framework.air.core.client.dto.search.xsfsi.AirXsfsiRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.detr.SunstnDetrReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.detr.SunstnDetrRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.detr.SunstnDetrRouteRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.etdz.SunstnEtdzReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.pat.SunstnPatPriceRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.pat.SunstnPatReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.pat.SunstnPatRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.patex.SunstnPatexReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.patex.SunstnPatexRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.rt.*;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.rtkt.SunstnRtktReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.rtkt.SunstnRtktRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.sd.SunstnSdReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.sd.SunstnSdRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.xepnr.SunstnXepnrReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.xepnr.SunstnXepnrRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.xsfsi.SunstnXsfsiReqDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.dto.xsfsi.SunstnXsfsiRespDTO;
import com.mercury.ec.framework.air.core.client.impl.sunstn.util.SunstnUtils;
import com.mercury.ec.framework.common.enums.CardTypeEnum;
import com.mercury.ec.module.basic.enums.BasicPassengerTypeEnum;

import java.util.ArrayList;
import java.util.List;

import static com.mercury.ec.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.mercury.ec.module.air.enums.ErrorCodeConstants.AIR_SUNSTN_API_CALL_EXCEPTION;

/**
 * 新港参数转换
 *
 * @author hesx
 */
public class SunstnConvert {

    /**
     * 获取新港RT请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnRtReqDTO getSunstnRtReqDTO(AirRtReqDTO reqDTO) {
        return new SunstnRtReqDTO(reqDTO.getScopeType(), reqDTO.getPnr(), reqDTO.getPatCmd(), reqDTO.getCustomerNo());
    }

    /**
     * 获取标准RT响应参数
     *
     * @param sunstnRtReqDTO
     * @param data
     * @return
     */
    public static AirRtRespDTO getAirRtRespDTO(SunstnRtReqDTO sunstnRtReqDTO, SunstnRtRespDTO data) {
        AirRtRespDTO airRtRespDTO = new AirRtRespDTO();
        airRtRespDTO.setPnr(data.getPnr());
        airRtRespDTO.setIssueOffice(SunstnUtils.getIssueOffice(data.getRemark()));
        airRtRespDTO.setPnrStatus(data.getLines().get(0).getState());
        airRtRespDTO.setBigPnr(data.getB_pnr());
        airRtRespDTO.setTeam(data.getIs_team());
        airRtRespDTO.setHaveCard(data.getHasNI());
        airRtRespDTO.setHaveBaby(data.getHasINF());
        airRtRespDTO.setChild(data.getIsCHD());
        airRtRespDTO.setRemark(data.getRemark());
        airRtRespDTO.setOsi(data.getOsi());
        airRtRespDTO.setHaveChild(false);
        airRtRespDTO.setHaveBaby(false);
//        if (data.getTk_date() != null && StrUtil.isNotBlank(data.getTk_time())) {
//            airRtRespDTO.setIssueTime(DateUtil.parseLocalDateTime(data.getTk_date().toString() + " " + data.getTk_time() + ":00"));
//        }
        airRtRespDTO.setPnrContent(data.getRaw_data());
//        airRtRespDTO.setXml(sunstnCommonRespDTO.getXml());

        // 航段信息
        if (CollUtil.isEmpty(data.getLines())) {
            throw exception(AIR_SUNSTN_API_CALL_EXCEPTION, sunstnRtReqDTO.getCmd(), "无航段信息");
        }
        List<AirRtRouteRespDTO> routes = new ArrayList<>();
        for (SunstnRtLineRespDTO line : data.getLines()) {
            AirRtRouteRespDTO airRtRouteRespDTO = new AirRtRouteRespDTO();
            airRtRouteRespDTO.setAirlineNo(line.getAirLine().substring(0, 2));
            airRtRouteRespDTO.setFlightNo(line.getAirLine().substring(2));
            airRtRouteRespDTO.setCabin(line.getCabin());
            airRtRouteRespDTO.setDiscount(line.getDiscount());
            airRtRouteRespDTO.setDepart(line.getDepartureCity());
            airRtRouteRespDTO.setArrive(line.getDestinationCity());
            airRtRouteRespDTO.setFlightDate(line.getDate());
            airRtRouteRespDTO.setDepartTime(line.getStartTime());
            if (line.getArriveTime().contains("+1")) {
                airRtRouteRespDTO.setFlightDays(1);
                airRtRouteRespDTO.setArriveTime(line.getArriveTime().replace("+1", ""));
            } else if (line.getArriveTime().contains("+2")) {
                airRtRouteRespDTO.setFlightDays(2);
                airRtRouteRespDTO.setArriveTime(line.getArriveTime().replace("+2", ""));
            } else {
                airRtRouteRespDTO.setFlightDays(0);
                airRtRouteRespDTO.setArriveTime(line.getArriveTime());
            }
            airRtRouteRespDTO.setDepartTerminal(line.getST());
            airRtRouteRespDTO.setArriveTerminal(line.getAT());
            airRtRouteRespDTO.setRouteStatus(line.getState());
            routes.add(airRtRouteRespDTO);
        }
        airRtRespDTO.setRoutes(routes);

        // 乘客信息
        if (CollUtil.isEmpty(data.getPassengers())) {
            throw exception(AIR_SUNSTN_API_CALL_EXCEPTION, sunstnRtReqDTO.getCmd(), "无乘客信息");
        }
        List<AirRtPassengerRespDTO> passengers = new ArrayList<>();
        for (SunstnRtPassengerRespDTO passenger : data.getPassengers()) {
            AirRtPassengerRespDTO airRtPassengerRespDTO = new AirRtPassengerRespDTO();
            airRtPassengerRespDTO.setName(passenger.getName());
            airRtPassengerRespDTO.setHaveBaby(false);
            // 根据乘客姓名区配乘客类型
            if (passenger.getName().contains("CHD")) {
                airRtRespDTO.setHaveChild(true);
                airRtPassengerRespDTO.setType(BasicPassengerTypeEnum.CHILD.getType());
            } else if (passenger.getName().contains("INF")) {
                airRtRespDTO.setHaveBaby(true);
                airRtPassengerRespDTO.setType(BasicPassengerTypeEnum.BABY.getType());
            } else {
                airRtPassengerRespDTO.setType(BasicPassengerTypeEnum.ADULT.getType());
            }
            airRtPassengerRespDTO.setCardType(IdcardUtil.isValidCard(passenger.getNI()) ? CardTypeEnum.IDCARD.getType() : null);
            airRtPassengerRespDTO.setCardNo(passenger.getNI());
            airRtPassengerRespDTO.setSex(SunstnUtils.getSexByIdCard(passenger.getNI()));
            airRtPassengerRespDTO.setBirthday(SunstnUtils.getBirthdayByIdCard(passenger.getNI()));
            if (StrUtil.isNotBlank(passenger.getTicket())) {
                String[] ticketArray = passenger.getTicket().split(","); // 连续票号用逗号分隔
                // 起始票号
                String ticketNo = ticketArray[0];
                airRtPassengerRespDTO.setAirlineIssueNo(ticketNo.substring(0, 3));
                airRtPassengerRespDTO.setTicketNo(ticketNo.substring(3));
                // 终止票号
                if (ticketArray.length > 1) {
                    String ticketLastNo = ticketArray[ticketArray.length - 1];
                    airRtPassengerRespDTO.setTicketLastNo(ticketLastNo.substring(11));
                }
            }
            airRtPassengerRespDTO.setMobile(passenger.getTEL());
            passengers.add(airRtPassengerRespDTO);
        }
        airRtRespDTO.setPassengers(passengers);

        // 价格信息
        List<AirRtPriceRespDTO> prices = new ArrayList<>();
        if (CollUtil.isNotEmpty(data.getPrices())) {
            for (SunstnRtPriceRespDTO price : data.getPrices()) {
                AirRtPriceRespDTO airRtPriceRespDTO = new AirRtPriceRespDTO();
                airRtPriceRespDTO.setFareBasis(price.getId());
                airRtPriceRespDTO.setTicketPrice(price.getFare());
                airRtPriceRespDTO.setAirportTax(price.getTax());
                airRtPriceRespDTO.setOilTax(price.getYQ());
                prices.add(airRtPriceRespDTO);
            }
        }
        airRtRespDTO.setPrices(prices);
        // 根据原文解析补充信息
        SunstnUtils.completeRtReulst(airRtRespDTO);
        return airRtRespDTO;
    }

    /**
     * 获取新港pat请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnPatReqDTO getSunstnPatReqDTO(AirPatReqDTO reqDTO) {
        return new SunstnPatReqDTO(reqDTO.getPnr(), reqDTO.getAll(), reqDTO.getPatCmd(), reqDTO.getCustomerNo());
    }

    /**
     * 获取标准pat响应参数
     *
     * @param reqDTO
     * @param data
     * @return
     */
    public static List<AirPatRespDTO> getAirPatRespDTO(AirPatReqDTO reqDTO, SunstnPatRespDTO data) {
        List<AirPatRespDTO> prices = new ArrayList<>();
        if (reqDTO.getAll()) {
            // 获取所有运价
            if (CollUtil.isNotEmpty(data.getPrices())) {
                for (SunstnPatPriceRespDTO price : data.getPrices()) {
                    AirPatRespDTO airPatRespVO = new AirPatRespDTO();
                    airPatRespVO.setNo(price.getId());
                    airPatRespVO.setTicketPrice(price.getCnyf());
                    airPatRespVO.setAirportTax(price.getCnycn());
                    airPatRespVO.setOilTax(price.getCnyyq());
                    prices.add(airPatRespVO);
                }
            }
        } else {
            // 获取最低运价
            AirPatRespDTO airPatRespVO = new AirPatRespDTO();
            airPatRespVO.setTicketPrice(data.getCnyf());
            airPatRespVO.setAirportTax(data.getCnycn());
            airPatRespVO.setOilTax(data.getCnyyq());
            prices.add(airPatRespVO);
        }
        return prices;
    }

    /**
     * 获取新港patex请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnPatexReqDTO getSunstnPatexReqDTO(AirPatexReqDTO reqDTO) {
        SunstnPatexReqDTO sunstnPatexReqDTO = new SunstnPatexReqDTO(reqDTO.getOffice(), reqDTO.getAll(), reqDTO.getChild(), reqDTO.getBaby(), reqDTO.getPatCmd(), reqDTO.getCustomerNo());
        sunstnPatexReqDTO.setAir_info(SunstnUtils.getSunstnPatexAirInfo(reqDTO.getRoutes()));
        return sunstnPatexReqDTO;
    }

    /**
     * 获取标准patex响应参数
     *
     * @param reqDTO
     * @param data
     * @return
     */
    public static List<AirPatexRespDTO> getAirPatexRespDTO(AirPatexReqDTO reqDTO, SunstnPatexRespDTO data) {
        List<AirPatexRespDTO> prices = new ArrayList<>();
        if (reqDTO.getAll()) {
            // 获取所有运价
            if (CollUtil.isNotEmpty(data.getPrices())) {
                for (SunstnPatPriceRespDTO price : data.getPrices()) {
                    AirPatexRespDTO airPatexRespDTO = new AirPatexRespDTO();
                    airPatexRespDTO.setNo(price.getId());
                    airPatexRespDTO.setTicketPrice(price.getCnyf());
                    airPatexRespDTO.setAirportTax(price.getCnycn());
                    airPatexRespDTO.setOilTax(price.getCnyyq());
                    prices.add(airPatexRespDTO);
                }
            }
            // 多价格时婴儿价放在单独对象
            if (reqDTO.getBaby() && data.getInfPrice() != null) {
                AirPatexRespDTO airPatexRespDTO = new AirPatexRespDTO();
                airPatexRespDTO.setTicketPrice(data.getInfPrice().getCnyf());
                airPatexRespDTO.setAirportTax(data.getInfPrice().getCnycn());
                airPatexRespDTO.setOilTax(data.getInfPrice().getCnyyq());
                prices.add(airPatexRespDTO);
            }
        } else {
            // 获取最低运价
            AirPatexRespDTO airPatexRespDTO = new AirPatexRespDTO();
            airPatexRespDTO.setTicketPrice(data.getCnyf());
            airPatexRespDTO.setAirportTax(data.getCnycn());
            airPatexRespDTO.setOilTax(data.getCnyyq());
            prices.add(airPatexRespDTO);
            // 最低价时获取婴儿价
            if (reqDTO.getBaby()) {
                AirPatexRespDTO airBabyPatexRespVO = new AirPatexRespDTO();
                airBabyPatexRespVO.setTicketPrice(data.getInf_cnyf());
                airBabyPatexRespVO.setAirportTax(data.getCnycn());
                airBabyPatexRespVO.setOilTax(data.getCnyyq());
                prices.add(airBabyPatexRespVO);
            }
        }
        return prices;
    }

    /**
     * 获取新港xsfsi请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnXsfsiReqDTO getSunstnXsfsiReqDTO(AirXsfsiReqDTO reqDTO) {
        SunstnXsfsiReqDTO sunstnXsfsiReqDTO = new SunstnXsfsiReqDTO(reqDTO.getPnr(), reqDTO.getCarrierAirlineNo(), SunstnUtils.getSunstnPassengerType(reqDTO.getPassengerType()));
        sunstnXsfsiReqDTO.setVoyage(SunstnUtils.getSunstnXsfsiVoyage(reqDTO.getRoutes()));
        return sunstnXsfsiReqDTO;
    }

    /**
     * 获取标准xsfsi响应参数
     *
     * @param reqDTO
     * @param data
     * @return
     */
    public static List<AirXsfsiRespDTO> getAirXsfsiRespDTO(AirXsfsiReqDTO reqDTO, SunstnXsfsiRespDTO data) {
        List<AirXsfsiRespDTO> prices = new ArrayList<>();
        // todo 待测试实际返回格式
//        if (xsfsiReqVO.getAll()) {
//            // 获取所有运价
//            if (CollUtil.isNotEmpty(data.getPrices())) {
//                for (SunstnPatPriceRespDTO price : data.getPrices()) {
//                    SunstnPatexRespVO sunstnPatexRespVO = new SunstnPatexRespVO();
//                    sunstnPatexRespVO.setNo(price.getId());
//                    sunstnPatexRespVO.setTicketPrice(price.getCnyf());
//                    sunstnPatexRespVO.setAirportTax(price.getCnycn());
//                    sunstnPatexRespVO.setOilTax(price.getCnyyq());
//                    prices.add(sunstnPatexRespVO);
//                }
//            }
//            // 多价格时婴儿价放在单独对象
//            if (patexReqVO.getBaby() && data.getInfPrice() != null) {
//                SunstnPatexRespVO sunstnPatexRespVO = new SunstnPatexRespVO();
//                sunstnPatexRespVO.setTicketPrice(data.getInfPrice().getCnyf());
//                sunstnPatexRespVO.setAirportTax(data.getInfPrice().getCnycn());
//                sunstnPatexRespVO.setOilTax(data.getInfPrice().getCnyyq());
//                prices.add(sunstnPatexRespVO);
//            }
//        } else {
//            // 获取最低运价
//            SunstnPatexRespVO sunstnPatexRespVO = new SunstnPatexRespVO();
//            sunstnPatexRespVO.setTicketPrice(data.getCnyf());
//            sunstnPatexRespVO.setAirportTax(data.getCnycn());
//            sunstnPatexRespVO.setOilTax(data.getCnyyq());
//            prices.add(sunstnPatexRespVO);
//            // 最低价时获取婴儿价
//            if (patexReqVO.getBaby()) {
//                SunstnPatexRespVO sunstnBabyPatexRespVO = new SunstnPatexRespVO();
//                sunstnBabyPatexRespVO.setTicketPrice(data.getInf_cnyf());
//                sunstnBabyPatexRespVO.setAirportTax(data.getCnycn());
//                sunstnBabyPatexRespVO.setOilTax(data.getCnyyq());
//                prices.add(sunstnBabyPatexRespVO);
//            }
//        }
        return prices;
    }

    /**
     * 获取新港detr请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnDetrReqDTO getSunstnDetrReqDTO(AirDetrReqDTO reqDTO) {
        return new SunstnDetrReqDTO(reqDTO.getAirlineIssueNo() + reqDTO.getTicketNo(), SunstnUtils.getSunstnCardType(reqDTO.getCardType()) + "/" + reqDTO.getCardNo());
    }

    /**
     * 获取标准detr响应参数
     *
     * @param data
     * @return
     */
    public static AirDetrRespDTO getAirDetrRespDTO(SunstnDetrRespDTO data) {
        AirDetrRespDTO airDetrRespDTO = new AirDetrRespDTO();
        airDetrRespDTO.setAirlineIssueNo(data.getTicket().getNo().substring(0, 3));
        airDetrRespDTO.setTicketNo(data.getTicket().getNo().substring(3));
        airDetrRespDTO.setTicketLastNo(data.getTicket().getACCESS_TKT());
        if (StrUtil.isNotBlank(data.getTicket().getEXCH())) {
            airDetrRespDTO.setChangeAirlineIssueNo(data.getTicket().getEXCH().split("-")[0]);
            airDetrRespDTO.setChangeTicketNo(data.getTicket().getEXCH().split("-")[1]);
        }
        airDetrRespDTO.setName(data.getTicket().getNAME());
        airDetrRespDTO.setCardNo(data.getTicket().getNI());
        airDetrRespDTO.setInvoiceNo(data.getTicket().getRP());
        airDetrRespDTO.setIssueDate(data.getTicket().getISSUEDATE());
        airDetrRespDTO.setIssueOffice(data.getTicket().getOFFICECODE());
        airDetrRespDTO.setTicketPrice(data.getTicket().getCNY());
        airDetrRespDTO.setAirportTax(data.getTicket().getTCNYCN());
        airDetrRespDTO.setOilTax(data.getTicket().getTCNYYQ());
        airDetrRespDTO.setAmount(data.getTicket().getACNY());
        airDetrRespDTO.setType(data.getTicket().getTKTYPE());
        airDetrRespDTO.setTicketType(SunstnUtils.getTicketTypeByDetr(data.getTicket().getPAYMENT()));
        airDetrRespDTO.setPnr(data.getTicket().getPNR());
        airDetrRespDTO.setBigPnr(data.getTicket().getBIGPNR());
        airDetrRespDTO.setTicketStatus(data.getTicket().getTKTSTATE());
        airDetrRespDTO.setTicketVendingMachineNo(data.getTicket().getPRINTDEV());
        airDetrRespDTO.setDetrContent(data.getRaw_data());

        // 行程信息
        List<AirDetrRouteRespDTO> routes = new ArrayList<>();
        if (CollUtil.isNotEmpty(data.getTicket().getRoutes())) {
            for (SunstnDetrRouteRespDTO route : data.getTicket().getRoutes()) {
                AirDetrRouteRespDTO airDetrRouteRespDTO = new AirDetrRouteRespDTO();
                airDetrRouteRespDTO.setSerialNo(route.getIndex());
                airDetrRouteRespDTO.setAirlineNo(route.getCARRIER().getCode());
                airDetrRouteRespDTO.setCarrierAirlineNo(route.getCARRIER().getCode());
                airDetrRouteRespDTO.setFlightNo(route.getFLIGHT());
                airDetrRouteRespDTO.setCabin(route.getCLASS());
                airDetrRouteRespDTO.setDiscount(route.getCLASSDISCOUNT());
                airDetrRouteRespDTO.setFareBasis(route.getFAREBASIS());
                airDetrRouteRespDTO.setDepart(route.getAIRPORTSTART().getCode());
                airDetrRouteRespDTO.setArrive(route.getAIRPORTARRIVE().getCode());
                airDetrRouteRespDTO.setFlightDate(route.getDATE());
                airDetrRouteRespDTO.setDepartTime(route.getTIME());
                airDetrRouteRespDTO.setDepartTerminal(route.getSTARTT());
                airDetrRouteRespDTO.setArriveTerminal(route.getARRIVALT());
                airDetrRouteRespDTO.setBaggageWeight(route.getALLOW());
                routes.add(airDetrRouteRespDTO);
            }
        }
        airDetrRespDTO.setRoutes(routes);
        return airDetrRespDTO;
    }

    /**
     * 获取新港rtkt请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnRtktReqDTO getSunstnRtktReqDTO(AirRtktReqDTO reqDTO) {
        return new SunstnRtktReqDTO(reqDTO.getAirlineIssueNo() + reqDTO.getTicketNo());
    }

    /**
     * 获取标准rtkt响应参数
     *
     * @param data
     * @return
     */
    public static AirRtktRespDTO getAirRtktRespDTO(SunstnRtktRespDTO data) {
        AirRtktRespDTO airRtktRespDTO = new AirRtktRespDTO();
        airRtktRespDTO.setAirlineIssueNo(data.getTicket().split("-")[0]);
        airRtktRespDTO.setTicketNo(data.getTicket().split("-")[1]);
        airRtktRespDTO.setTicketType(SunstnUtils.getTicketTypeByRtkt(data.getTicket_type()));
        airRtktRespDTO.setPnr(data.getPnr());
        airRtktRespDTO.setAirlineName(data.getCarrier());
        airRtktRespDTO.setIssueDate(data.getIssue_date());
        airRtktRespDTO.setTicketVendingMachineNo(data.getEtdz_device());
        airRtktRespDTO.setPassengerName(data.getPassenger());
        airRtktRespDTO.setTicketPrice(NumberUtil.nullToZero(data.getTicket_fare()));
        airRtktRespDTO.setTax(NumberUtil.nullToZero(data.getTax()));
        airRtktRespDTO.setAmount(NumberUtil.nullToZero(data.getTotal_fare()));
        airRtktRespDTO.setAgencyFee(NumberUtil.nullToZero(data.getAgent_rate()));
        airRtktRespDTO.setFareBasis(data.getRoutes().get(0).getFarebasis());
        return airRtktRespDTO;
    }

    /**
     * 获取新港sd请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnSdReqDTO getSunstnSdReqDTO(AirOrderCreateReqDTO reqDTO) {
        SunstnSdReqDTO sunstnSdReqDTO = new SunstnSdReqDTO();
        sunstnSdReqDTO.setSline(SunstnUtils.getSunstnSline(reqDTO.getContactMobile(), reqDTO.getRoutes()));
        sunstnSdReqDTO.setAir_info(SunstnUtils.getSunstnSdAirInfo(reqDTO.getRoutes()));
        sunstnSdReqDTO.setSsr_info(SunstnUtils.getSunstnSdSsrInfo(reqDTO.getPassengers(), reqDTO.getRoutes()));
        return sunstnSdReqDTO;
    }

    /**
     * 获取标准创建订单响应参数
     *
     * @param data
     * @return
     */
    public static AirOrderCreateRespDTO getAirOrderCreateRespDTO(SunstnSdRespDTO data) {
        AirOrderCreateRespDTO airOrderCreateRespDTO = new AirOrderCreateRespDTO();
        airOrderCreateRespDTO.setSuccess(true);
        airOrderCreateRespDTO.setOrderNo(data.getRets().get(0).getPnr());
        return airOrderCreateRespDTO;
    }

    /**
     * 获取新港取消订单请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnXepnrReqDTO getSunstnXepnrReqDTO(AirOrderCancelReqDTO reqDTO) {
        SunstnXepnrReqDTO sunstnXepnrReqDTO = new SunstnXepnrReqDTO();
        sunstnXepnrReqDTO.setPnr(reqDTO.getOrderNo());
        return sunstnXepnrReqDTO;
    }

    /**
     * 获取标准取消订单响应参数
     *
     * @param data
     * @return
     */
    public static AirOrderCancelRespDTO getAirOrderCancelRespDTO(SunstnXepnrRespDTO data) {
        AirOrderCancelRespDTO airOrderCancelRespDTO = new AirOrderCancelRespDTO();
        airOrderCancelRespDTO.setSuccess(true);
        return airOrderCancelRespDTO;
    }

    /**
     * 获取新港etdz请求参数
     *
     * @param reqDTO
     * @return
     */
    public static SunstnEtdzReqDTO getSunstnEtdzReqDTO(AirOrderIssueReqDTO reqDTO) {
        SunstnEtdzReqDTO sunstnEtdzReqDTO = new SunstnEtdzReqDTO();
        sunstnEtdzReqDTO.setPnr(reqDTO.getPnr());
        sunstnEtdzReqDTO.setOfficecode(reqDTO.getOfficeNo());
        sunstnEtdzReqDTO.setPrintid(reqDTO.getTicketVendingMachineNo());
        if (StrUtil.isNotBlank(reqDTO.getCardNo())) {
            // uatp出票 CCV:TP122000200594946/1260.00/0617/CNY
            sunstnEtdzReqDTO.setUatp_ccv("CCV:TP" + reqDTO.getCardNo()+ "/" + NumberUtil.decimalFormat("0.00", reqDTO.getAmount()) + "/" + LocalDateTimeUtil.format(reqDTO.getCardNoValidDate(), "MMyy") + "/CNY");
        }
//        sunstnEtdzReqDTO.setEi();
//        sunstnEtdzReqDTO.setCt();
//        sunstnEtdzReqDTO.setPrice();
//        sunstnEtdzReqDTO.setPat_cmd();
        sunstnEtdzReqDTO.setFare_basis(reqDTO.getFareBasis());
        sunstnEtdzReqDTO.setCustomer_code(reqDTO.getCustomerAgreementNo());
//        sunstnEtdzReqDTO.setDpay_pwd();
//        sunstnEtdzReqDTO.setEtdz_cmd();
        return sunstnEtdzReqDTO;
    }
}
